﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using COM.OA.BLL;
using System.Collections.Generic;
using COM.OA.Entity;

public partial class rc_jh_writeplan : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    //提交按钮
    protected void Button1_Click(object sender, EventArgs e)
    {
        //主题
        string title=this.Request.Form["txtTitle"];
        //内容
        string content = this.ftbContent.Text;
        //日期
        string orderdate = DateTime.Now.ToString("yyyy-MM-dd");
        //发送人
        string username = this.Request.Form["txtusername"];
        //发送人id
        int userid = 0;

        string sql3 = "u_username='{0}'";
        sql3 = string.Format(sql3, username);
        IList<users> userlist = usersBLL.Select(sql3);
        if (userlist.Count == 1)
        {
            foreach (users u in userlist)
            {
                userid = u.u_id;
            }
        }
        //发送时间
        DateTime sendtime = DateTime.Parse(this.Request.Form["txtsendtime"]);
        //状态
        int state = 1;
        //读否
        int isread = 0;
        //读写人id
        int readerid = 1;
        //读写内容
        string readcontent = "";
        //读写时间
        string readtime = DateTime.Now.ToString("yyyy-MM-dd");

        timeorder torder = new timeorder();
        torder.to_orderdate =  DateTime.Parse(orderdate);//日程日期
        torder.to_title = title;//标题
        torder.to_content = content;//内容
        torder.to_u_id = userid;//发送人id
        torder.to_sendtime = sendtime;//发送时间
        torder.to_state = state; //状态
        torder.to_isread = isread;//是否批阅
        torder.to_readerid = readerid;//批阅人id
        torder.to_readcontent = readcontent;//批阅内容
        torder.to_readtime = DateTime.Parse(readtime); //批阅时间

        int flag = timeorderBLL.Insert(torder);
        if (flag == 0)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>alert('计划发送失败！！');</script>");
        }
        this.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>alert('计划发送成功！！');</script>");
        this.Response.Redirect("jh_myplan.aspx");

    }
}
